<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	    		xmlns:ui="http://java.sun.com/jsf/facelets"
	  			xmlns:h="http://java.sun.com/jsf/html"
	  			xmlns:f="http://java.sun.com/jsf/core"               
                xmlns:cs="http://myfaces.apress.com/custom"
				template="/WEB-INF/layouts/standard.xhtml"
				xmlns:a4j="http://richfaces.org/a4j"
				xmlns:rich="http://richfaces.org/rich"
				xmlns:bf="http://www.bssmanager.com/jsf"
				xmlns:c="http://java.sun.com/jstl/core"
				xmlns:fn="http://java.sun.com/jsp/jstl/functions">

	<ui:define name="headIncludes">
		<style>
			.class11 {
				border-top: 1px solid gray;
			}
		</style>
	</ui:define>
	
	<ui:define name="content">
		<h:form id="#{dailyRevenueController.modelName}" >		
			<h2>Daily Deposit and Refund</h2>			
			<rich:panel style="border:0px;">					
				<table width="100%" align="left" style="text-align: left; table-layout: fixed">			
					<tr style="background-color: #FFBF80">
						<td colspan="4" style="font-weight: bolder; font-size: 10pt;" align="left">
							Todays Deposit and Refund
						</td>
						<td colspan="1" style="font-weight: bolder; font-size: 10pt;" align="left">
							Last Report Generated
						</td>
					</tr>
					<tr>				
						<td colspan="2" valign="top"><div style="background-color: yellow;"></div>								
								<h:panelGrid columns="3">									
									<h:outputLabel value="Date: "/>
									<rich:calendar enableManualInput="false" value="#{dailyDepositAndRefundController.model.date}" inputSize="12"
										datePattern="dd MMM yy HH:mm">
										<a4j:support event="onchanged" reRender="dailyDepositRefund,dailyCashBalance"
														action="#{dailyDepositAndRefundController.doTotal}" 
															status="drdate"
															oncomplete="if(#{not empty dailyDepositAndRefundController.errors})alert('#{dailyDepositAndRefundController.errors[0]}');" />
									</rich:calendar>
									<a4j:status forceId="true" id="drdate" >
										 <f:facet name="start">
							                  <h:graphicImage value="/images/im1.gif"/>
							             </f:facet>
									</a4j:status>														
								</h:panelGrid>
						</td>
						<td colspan="1" align="left">
							<div align="center">
								<h:commandButton value="Generate Report" styleClass="noprint" action="#{dailyDepositAndRefundController.add}"/>
							</div>	
						</td>
						<td colspan="1"/>
						<td colspan="1">
							<h:outputText value="#{dailyDepositAndRefundController.model.lastReportGeneratedDate}" style="background-color: yellow;">
								<f:convertDateTime pattern="dd MMM yy HH:mm" />
							</h:outputText>
						</td>
					</tr>
					<tr style="background-color: #FFBF80">
						<td colspan="5" style="font-weight: bolder; font-size: 10pt;" align="center">
							Todays Deposit and Refund
						</td>						
					</tr>		
					<tr>
						<td colspan="3" valign="top">
							<h:panelGrid id="dailyDepositRefund" columns="5" border="1">
								<h:panelGrid columns="1" footerClass="class11">
									<f:facet name="header">
										<h:outputText value=" "/>
									</f:facet>
									<h:outputLabel value="S/N"/>
									<c:forEach begin="1" end="#{dailyDepositAndRefundController.model.rows}" var="cnt"
												step="1">
										<h:outputLabel value="#{cnt}"/>
									</c:forEach>
									<h:outputLabel value=" "/>
								</h:panelGrid>					
								<h:panelGrid columns="2" footerClass="class11">
									<f:facet name="header">
										<h:outputLabel value="Room Deposit"/>
									</f:facet>
									<h:outputLabel value="ID "/>
									<h:outputLabel value="Amount" style="float:right;"/>
									<c:set var="i" value="0"/>									
									<c:forEach items="#{dailyDepositAndRefundController.model.roomDepositAndRefunds}" var="rdr">
										<c:if test="#{!rdr.refund}">
											<h:outputText value="#{rdr.id}" />
											<h:outputText value="#{rdr.amount}" style="float:right; height:15px;"/>
											<c:set var="i" value="#{i + 1}"/>
										</c:if>
									</c:forEach>																													
									<c:forEach begin="#{i+0}" end="#{dailyDepositAndRefundController.model.rows - 1}" 
												step="1">
										<h:outputText value=""/>
										<h:outputText value="-" style="float:right;"/>
									</c:forEach>
									<f:facet name="footer">
										<h:outputLabel value="-"/>
										<h:outputLabel value="#{dailyDepositAndRefundController.model.roomDepositTotal}" style="float:right;"/>
									</f:facet>								
								</h:panelGrid>
								<h:panelGrid columns="2" footerClass="class11">
									<f:facet name="header">
										<h:outputLabel value="Room Refund"/>
									</f:facet>
									<h:outputLabel value="ID "/>
									<h:outputLabel value="Amount" style="float:right;"/>																				
									<c:set var="i" value="0"/>									
									<c:forEach items="#{dailyDepositAndRefundController.model.roomDepositAndRefunds}" var="rdr">
										<c:if test="#{rdr.refund}">
											<h:outputText value="#{rdr.id}" />
											<h:outputText value="#{rdr.amount}" style="float:right;"/>
											<c:set var="i" value="#{i + 1}"/>
										</c:if>
									</c:forEach>
									<c:forEach begin="#{i+0}" end="#{dailyDepositAndRefundController.model.rows - 1}" 
										step="1">
										<h:outputText value=""/>
										<h:outputText value="-" style="float:right;"/>
									</c:forEach>							
									<f:facet name="footer">
										<h:outputLabel value="#{dailyDepositAndRefundController.model.roomRefundTotal}" style="float:right;"/>
									</f:facet>
								</h:panelGrid>
								<h:panelGrid columns="2" footerClass="class11">
									<f:facet name="header">
										<h:outputLabel value="Utensil Deposit"/>
									</f:facet>
									<h:outputLabel value="ID "/>
									<h:outputLabel value="Amount" style="float:right;"/>																				
									<c:set var="i" value="0"/>	
									<c:forEach items="#{dailyDepositAndRefundController.model.utensilDepositAndRefunds}" var="rdr">
										<c:if test="#{!rdr.refund}">
											<h:outputText value="#{rdr.id}" />
											<h:outputText value="#{rdr.amount}" style="float:right;"/>
											<c:set var="i" value="#{i + 1}"/>
										</c:if>
									</c:forEach>
									<c:forEach begin="#{i+0}" end="#{dailyDepositAndRefundController.model.rows - 1}" 
										step="1">
										<h:outputText value=""/>
										<h:outputText value="-" style="float:right;"/>
									</c:forEach>										
									<f:facet name="footer">
										<h:outputLabel value="#{dailyDepositAndRefundController.model.utensilDepositTotal}" style="float:right;"/>
									</f:facet>								
								</h:panelGrid>	
								<h:panelGrid columns="2" footerClass="class11">
									<f:facet name="header">
										<h:outputLabel value="Utensil Refund"/>
									</f:facet>
									<h:outputLabel value="ID "/>
									<h:outputLabel value="Amount" style="float:right;"/>																				
									<c:set var="i" value="0"/>
									<c:forEach items="#{dailyDepositAndRefundController.model.utensilDepositAndRefunds}" var="rdr">
										<c:if test="#{rdr.refund}">
											<h:outputText value="#{rdr.id}" />
											<h:outputText value="#{rdr.amount}" style="float:right;"/>
											<c:set var="i" value="#{i + 1}"/>
										</c:if>
									</c:forEach>
									<c:forEach begin="#{i+0}" end="#{dailyDepositAndRefundController.model.rows - 1}" 
											step="1">
										<h:outputText value=""/>
										<h:outputText value="-" style="float:right;"/>
									</c:forEach>
									<f:facet name="footer">
										<h:outputText value="#{dailyDepositAndRefundController.model.utensilRefundTotal}" style="float:right;"/>
									</f:facet>
								</h:panelGrid>								
							</h:panelGrid>		
						</td>
						
						<td valign="top" colspan="2">
							<h:panelGrid id="dailyCashBalance" columns="6" border="1">
								<f:facet name="header">
									<h:outputLabel value="Cash Balance"/>			
								</f:facet>
								<h:outputText value=" "/>
								<h:outputText value="Deposit"/>
								<h:outputText value="Refund"/>								
								<h:outputText value="Balance"/>
								<h:outputText value="Opening"/>
								<h:outputText value="Closing"/>
								<h:outputText value="Room"/>
								<h:outputText value="#{dailyDepositAndRefundController.model.roomDepositTotal}" style="float:right;"/>
								<h:outputText value="#{dailyDepositAndRefundController.model.roomRefundTotal}" style="float:right;"/>
								<h:outputText value="#{dailyDepositAndRefundController.model.roomDepositTotal - dailyDepositAndRefundController.model.roomRefundTotal}" style="float:right;"/>
								<h:outputText value="#{dailyDepositAndRefundController.model.securityDeposit.balance}" style="float:right;"/>								
								<h:outputText value="#{dailyDepositAndRefundController.model.securityDeposit.balance + dailyDepositAndRefundController.model.roomDepositTotal - dailyDepositAndRefundController.model.roomRefundTotal }" style="float:right;"/>
								<h:outputText value="Utensil"/>								
								<h:outputText value="#{dailyDepositAndRefundController.model.utensilDepositTotal}" style="float:right;"/>
								<h:outputText value="#{dailyDepositAndRefundController.model.utensilRefundTotal}" style="float:right;"/>
								<h:outputText value="#{dailyDepositAndRefundController.model.utensilDepositTotal - dailyDepositAndRefundController.model.utensilRefundTotal}" style="float:right;"/>
								<h:outputText value="#{dailyDepositAndRefundController.model.utensilDeposit.balance}" style="float:right;"/>
								<h:outputText value="#{dailyDepositAndRefundController.model.utensilDeposit.balance + dailyDepositAndRefundController.model.utensilDepositTotal - dailyDepositAndRefundController.model.utensilRefundTotal}" style="float:right;"/>
								<h:outputText value=" "/>
								<h:outputText value=" "/>
								<h:outputText value="Final: "/>
								<h:outputText value="#{dailyDepositAndRefundController.model.roomDepositTotal - dailyDepositAndRefundController.model.roomRefundTotal + dailyDepositAndRefundController.model.utensilDepositTotal - dailyDepositAndRefundController.model.utensilRefundTotal}" style="float:right;"/>																																																														
							</h:panelGrid>													
						</td>
					</tr>					
				</table>					
			</rich:panel>				
		</h:form>		
	</ui:define>
</ui:composition>